//
//  PieceView.m
//  MyDota
//
//  Created by 濮亚军 on 15/12/2.
//  Copyright © 2015年 濮亚军. All rights reserved.
//

#import "PieceView.h"
@interface PieceView()

//背景
@property(nonatomic, strong)UIView *BgView;

@end
@implementation PieceView
#pragma mark --------重写init方法--------
-(instancetype)initWithFrame:(CGRect)frame image:(UIImage *)image title:(NSString *)title
{
    self = [super initWithFrame:frame];
    if (self)
    {
        //背景
        self.BgView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
        //self.BgView.backgroundColor = [UIColor greenColor];
        [self addSubview:_BgView];
        
        CGFloat height = frame.size.height - 20 * kHProportion;
        CGFloat x = (frame.size.width - height) / 2;
        
        //可点击的按钮
        self.clickImageView = [[UIImageView alloc]initWithFrame:CGRectMake( x, 2 * kHProportion, height, height)];
        //self.clickImageView.backgroundColor = [UIColor blackColor];
        self.clickImageView.userInteractionEnabled = YES;
        self.clickImageView.image = image;
        [self.BgView addSubview:_clickImageView];
        
        //标题
        self.titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(x, height + 5 * kHProportion, height, 10 * kHProportion)];
        //self.titleLabel.backgroundColor = [UIColor blackColor];
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
        self.titleLabel.textColor = [UIColor whiteColor];
        self.titleLabel.text = title;
        self.titleLabel.font = [UIFont systemFontOfSize:12];
        [self.BgView addSubview:_titleLabel];
        
    }
    return self;
}
@end
